/**
 * 路径分析
 * @author cqb
 * @class OpenLayers.Control.BufferPolygonAnalysis
 * @extends OpenLayers.Control.BufferPointAnalysis
 * @version 1.0
 * @requires extend/Control/BufferPointAnalysis.js
 */

OpenLayers.Control.BufferPolygonAnalysis = OpenLayers.Class(OpenLayers.Control.BufferPointAnalysis,{
	/**
	 * Property: title {String} 工具按钮提示文字
	 */
	title : "面缓冲分析",
	

	/**
	 * Method: activate 控件被触发时设置鼠标手势
	 */
	activate : function() {
		OpenLayers.Control.BufferPointAnalysis.prototype.activate.apply(this,arguments);
		this.map.layerContainerDiv.style.cursor = "url("
				+ OpenLayers.Util.getRootPath()
				+ "img/bufferploygon.cur),default";
	},

	/**
	 * Method: draw
	 */
	draw : function() {
        var symbolizers = {
            "Point": {
                pointRadius: 0,
                fillOpacity: 0,
                strokeWidth: 0,
                strokeOpacity: 0
            }
        };
        var style = new OpenLayers.Style();
        style.addRules([
        new OpenLayers.Rule({symbolizer: symbolizers})]);
        
        var styleMap = new OpenLayers.StyleMap({"default": style});

		this.handler = new OpenLayers.Handler.Polygon(this, {
			done : this.bufferQuery
		},{
			layerOptions: {
				styleMap: styleMap
			}
		});
        
        var modifyFeature = this.handler.modifyFeature;
		var scope = this;
		this.handler.modifyFeature = function(pixel, drawing){
            modifyFeature.apply(scope.handler, arguments);
            scope.map.layerContainerDiv.style.cursor = "url("+OpenLayers.Util.getRootPath() + "img/bufferploygon.cur),default";
		}
	},
	
	/**
	 * 开始查询 
	 * @method bufferQuery
	 * @param evt {OpenLayers.Event} 事件
	 */
	bufferQuery : function(evt) {
	    if(evt.components[0].components.length < 4){
	        alert("操作不正确，请重新绘制多边形");
	        return false;
	    }
        var format = new OpenLayers.Format.WKT();
	    var wkt = format.extractGeometry(evt);
        this.queryend(wkt);
        this.deactivate();
	},
	
	CLASS_NAME : "OpenLayers.Control.BufferPolygonAnalysis"
});